﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using dao;
namespace GTVAccountingSystem.view.form
{
    public partial class frmFeedback : Form
    {
        frmMain main;
        int index;
        String subjectText = "";
        String contentsText = "";
        String error = "";
        PopupManagerDAO popupManager = new PopupManagerDAO();
       
        public frmFeedback(frmMain main, int index)
        {
            this.index = index;
            this.main = main;
            InitializeComponent();
        }
        public void validateData()
        {
            subjectText = txtSubject.Text.Trim();
            contentsText = txtContent.Text.Trim();
            txtSubject.BackColor = System.Drawing.SystemColors.Window;
            error = "";
            if (subjectText.Equals(""))
            {
                error += "Input subject";
                txtSubject.BackColor = System.Drawing.Color.MistyRose;
            }
            if (contentsText.Equals(""))
            {
                error += "Input feedback";
            }
        }
        private void btnSendFeedback_Click(object sender, EventArgs e)
        {
            validateData();
            if (error.Equals(""))
            {
                if (popupManager.sendFeedback(subjectText, subjectText))
                    MessageBox.Show("Send feedback successful", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show(error, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

        private void frmFeedback_FormClosing(object sender, FormClosingEventArgs e)
        {
            main.listOpen.RemoveAt(index);
        }
    }
}
